import { useSelector } from 'react-redux'
import type { StateType } from '../../../store/types'
import type { ComponentState } from '../../../store/components-reducer/types'

export default function useGetComponentInfo() {
  const {
    componentList = [],
    selectedId = '',
    copiedComponent,
  } = useSelector<StateType>(state => state.component.present) as ComponentState

  const selectedComponent = componentList.find(c => c.fe_id === selectedId)

  return { componentList, selectedId, selectedComponent, copiedComponent }
}
